from src import index

import cherrypy, os

working_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'src')

# CherryPy
conffile = os.path.join(os.path.dirname(__file__), 'src/cherrypy.conf')
confdict = {
	'/': {
			'tools.staticdir.on': True, 
			'tools.staticdir.dir': working_dir, 
			'tools.staticdir.index': 'index.html'
	},
	'/media': {
			'tools.staticdir.on': True, 
			'tools.staticdir.dir': working_dir + '/media'
	}
}

cherrypy.config.update(conffile)
cherrypy.config.update(confdict)

app = cherrypy.tree.mount(index.SolrMp3(), '/', conffile)
app.merge(confdict)

if hasattr(cherrypy.engine, "signal_handler"):
	cherrypy.engine.signal_handler.subscribe()  
if hasattr(cherrypy.engine, "console_control_handler"):
	cherrypy.engine.console_control_handler.subscribe()

cherrypy.engine.start()
cherrypy.engine.block()
